package com.panshi.modules.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panshi.modules.domain.UserMember;
import com.panshi.modules.mapper.MemberMapper;
import com.panshi.modules.mapper.UserMapper;
import com.panshi.modules.service.MemberService;
import com.panshi.vo.SearchVO;
import com.panshi.vo.StatusVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public IPage pageMemberList(SearchVO searchVO) {
        IPage<UserMember> page = new Page<>(searchVO.getCurrentPage(),searchVO.getPageSize());
        page = memberMapper.selectPage(page, null);
        return page;
    }

    @Override
    public int editMemberStatus(StatusVO statusVO) {
        UserMember userMember = new UserMember();
        BeanUtils.copyProperties(statusVO,userMember);
        return memberMapper.updateById(userMember);
    }
}
